﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BUS;
using DTO;


namespace CungMuaC5.Account_Admin
{
    public partial class Comment_Sua : System.Web.UI.Page
    {
        int MaCM;
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Fill();
            }
        
        }
        private void Fill()
        {
            BUS_Comment bus = new BUS_Comment();

            string text = "~/Products/ProductDetail.aspx?makm=";
            MaCM = int.Parse(Request.QueryString["ma"].ToString());
            List<DTO_Comment1> list = new List<DTO_Comment1>();
            list = bus.TimKiemTheoMaCM(MaCM);
            
            text = text + list[0].MaKhuyenMai.ToString();
            hyperlink1.NavigateUrl = text;
            hyperlink1.Text = list[0].KhuyenMai;
            switch (list[0].TinhTrang)
            {
                case 0: Label9.Text = "Chưa Duyệt";
                    break;
                case 1: Label9.Text = "Đã Duyệt";
                    break;
                case 2: Label9.Text = "Đã Xóa";
                    break;
            }
            Label1.Text = list[0].MaComment.ToString();
            Label7.Text = list[0].ThoiGian.ToString();
            Label3.Text = list[0].NguoiPost;
            TextBox1.Text = list[0].NoiDung;
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            BUS_Comment bus = new BUS_Comment();
            MaCM = int.Parse(Request.QueryString["ma"].ToString());
            
            string text = TextBox1.Text;
            bool i=bus.Update(MaCM, text);
            if(i==true)
                Button2.Attributes.Add("onclick", "alert('Đã lưu thay đổi !')");
            else
                Button2.Attributes.Add("onclick", "alert('Không Lưu được !')");
            
            
        }

    }
}